﻿<%@ Page Title="Moje zprávy" Language="C#" MasterPageFile="~/Pages/Site.Master" AutoEventWireup="true" CodeBehind="Messages.aspx.cs" Inherits="Altairis.FluffyCloud.WebCore.Pages.My.Messages" %>
<asp:Content ContentPlaceHolderID="Main" runat="server">
    <div class="iconbar">
        <asp:HyperLink ID="FeedLink" runat="server" Text="RSS feed" CssClass="rss" ToolTip="RSS feed" />
    </div>
    <h1>
        <asp:Literal ID="LiteralTitle" Text="Moje zprávy" runat="server" />
    </h1>
    <div class="form">
        <div>
            <asp:Label Text="Příjemce:" runat="server" AssociatedControlID="RecipientList" /><br />
            <asp:DropDownList ID="RecipientList" runat="server" SelectMethod="RecipientList_GetData" DataTextField="Text" DataValueField="Value" AppendDataBoundItems="true">
                <asp:ListItem />
            </asp:DropDownList>
            <asp:RequiredFieldValidator runat="server" ControlToValidate="RecipientList" Display="None" ErrorMessage="Není zadán příjemce zprávy" />
        </div>
        <div>
            <asp:Label runat="server" Text="Text zprávy:" AssociatedControlID="TextTextBox" />
            <br />
            <asp:TextBox ID="TextTextBox" runat="server" TextMode="MultiLine" Height="150px" data-exteditortype="wikimarkup" />
            <asp:RequiredFieldValidator runat="server" ControlToValidate="TextTextBox" Display="None" ErrorMessage="Není zadán text zprávy" />
        </div>
        <asp:ValidationSummary runat="server" />
        <div>
            <asp:Button Text="Odeslat" runat="server" ID="ButtonSend" OnClick="ButtonSend_Click" />
        </div>
    </div>
    <asp:ListView ID="MessageList" runat="server" ItemType="Altairis.FluffyCloud.Data.Message" DataKeyNames="MessageId" SelectMethod="MessageList_GetData">
        <EmptyDataTemplate>
            <p>Nemáte žádné přijaté ani odeslané zprávy.</p>
        </EmptyDataTemplate>
        <LayoutTemplate>
            <section class="postlist">
                <asp:PlaceHolder ID="ItemPlaceHolder" runat="server" />
                <footer>
                    <div class="left">
                        <asp:HyperLink ID="LinkFirst" runat="server" Text="&#x25C0; nejnovější" />
                        <asp:HyperLink ID="LinkPrevious" runat="server" Text="&#x25C0; novější" />
                    </div>
                    <div class="right">
                        <asp:HyperLink ID="LinkNext" runat="server" Text="starší &#x25B6;" />
                        <asp:HyperLink ID="LinkLast" runat="server" Text="nejstarší &#x25B6;" />
                    </div>
                    <asp:Literal ID="LiteralPagerInfo" runat="server" Text="celkem {2} zpráv, stránka {3} z {4} " />
                </footer>
            </section>
        </LayoutTemplate>
        <ItemTemplate>
            <asp:PlaceHolder runat="server" Visible="<%# Item.ToUserName.Equals(this.User.Identity.Name, StringComparison.CurrentCultureIgnoreCase) %>">
                <article id="<%#: Item.MessageId %>" class="msgin">
                    <aside>
                        <my:UserIcon runat="server" UserName="<%# Item.FromUserName %>" Size="50" ToolTip="Odesílatel" NavigateUrl='<%# this.GetRouteUrl("MyUserMessages", new { userName = Item.FromUserName}) %>' />
                    </aside>
                    <header>
                        <div class="more">
                            <%#: "odesláno " + Item.DateCreated.ToLocalDisplayFormat() %>
                            <asp:Label CssClass="new" Text="nová zpráva" runat="server" Visible="<%# !Item.DateRead.HasValue  %>" />
                        </div>
                        <span class="dir" title="Přijato od uživatele">&#x25C0;</span>
                        <asp:HyperLink ToolTip="Přijato od uživatele" NavigateUrl='<%# this.GetRouteUrl("UserProfile", new { username = Item.FromUserName }) %>' Text="<%#: Item.FromUserName %>" runat="server" CssClass="username" />
                        <asp:Label Text="<%#: Item.FromUser.Comment %>" runat="server" CssClass="usercomment" />
                    </header>
                    <my:WikiMarkup runat="server" Text="<%# Item.Text %>" />
                </article>
            </asp:PlaceHolder>
            <asp:PlaceHolder runat="server" Visible="<%# !Item.ToUserName.Equals(this.User.Identity.Name, StringComparison.CurrentCultureIgnoreCase) %>">
                <article id="<%#: Item.MessageId %>" class="msgout">
                    <aside>
                        <my:UserIcon runat="server" UserName="<%# Item.ToUserName %>" Size="50" ToolTip="Adresát" NavigateUrl='<%# this.GetRouteUrl("MyUserMessages", new { userName = Item.ToUserName }) %>' />
                    </aside>
                    <header>
                        <div class="more">
                            <%#: "odesláno " + Item.DateCreated.ToLocalDisplayFormat() %>
                            <%#: Item.DateRead.HasValue ? ", přečteno " + Item.DateRead.Value.ToLocalDisplayFormat() : ", dosud nepřečteno na webu" %>
                        </div>
                        <span class="dir" title="Odesláno uživateli">&#x25B6;</span>
                        <asp:HyperLink ToolTip="Odesláno uživateli" NavigateUrl='<%# this.GetRouteUrl("UserProfile", new { username = Item.ToUserName }) %>' Text="<%#: Item.ToUserName %>" runat="server" CssClass="username" />
                        <asp:Label Text="<%#: Item.ToUser.Comment %>" runat="server" CssClass="usercomment" />
                    </header>
                    <my:WikiMarkup runat="server" Text="<%# Item.Text %>" />
                </article>
            </asp:PlaceHolder>
        </ItemTemplate>
    </asp:ListView>
    <altairis:DataPagerExtender runat="server" TargetControlID="MessageList" PageSize="20" PageIndexSource="RouteParameter" FirstLinkID="LinkFirst" LastLinkID="LinkLast" NextLinkID="LinkNext" PreviousLinkID="LinkPrevious" InfoLabelID="LiteralPagerInfo" InactiveLinkMode="Disable" />
</asp:Content>